#ifndef HTTPSERVER_H
#define HTTPSERVER_H

#include "httplib.h"

//
// 用户请求到本服务, 作为 httpserver 解析客户端请求, 需要用到的函数,
//


namespace nmsp
{
    std::string dump_headers(const httplib::Headers &headers);
    std::string log(const httplib::Request &req, const httplib::Response &res);

    class Httpserver
    {
    public:
        int Register();
        httplib::Server &Get(const std::string &pattern, httplib::Server::Handler handler) { return m_serv.Get(pattern, handler); }
        httplib::Server &Post(const std::string &pattern, httplib::Server::Handler handler) { return m_serv.Post(pattern, handler); }
        httplib::Server &Post(const std::string &pattern, httplib::Server::HandlerWithContentReader handler) { return m_serv.Post(pattern, handler); }
        httplib::Server &Put(const std::string &pattern, httplib::Server::Handler handler) { return m_serv.Put(pattern, handler); }
        httplib::Server &Put(const std::string &pattern, httplib::Server::HandlerWithContentReader handler) { return m_serv.Put(pattern, handler); }
        httplib::Server &Patch(const std::string &pattern, httplib::Server::Handler handler) { return m_serv.Patch(pattern, handler); }
        httplib::Server &Patch(const std::string &pattern, httplib::Server::HandlerWithContentReader handler) { return m_serv.Patch(pattern, handler); }
        httplib::Server &Delete(const std::string &pattern, httplib::Server::Handler handler) { return m_serv.Delete(pattern, handler); }
        httplib::Server &Delete(const std::string &pattern, httplib::Server::HandlerWithContentReader handler) { return m_serv.Delete(pattern, handler); }
        httplib::Server &Options(const std::string &pattern, httplib::Server::Handler handler) { return m_serv.Options(pattern, handler); }
        bool Listen(const char *host, int port) { return m_serv.listen(host, port); }

    private:
        httplib::Server m_serv;
    };

}
#endif

